
#[cfg(test)]
mod test{
    use crate::models::crypto::aead::*;
    use crate::util::util::AsStr;

    #[test]
    fn test_rang_bytes(){
        let data = rang_bytes(16);
        let endata = base64_encode(data.as_slice());
        println!("{}",endata);
        let dedata = base64_decode(endata.as_bytes()).unwrap();
        assert_eq!(dedata,data,"failed")
    }
    #[test]
    fn test_aes_cbc(){
        let key = rang_bytes(32);
        let iv = rang_bytes(16);
        let msg = b"hello world";
        let res = aes_cbc_encode("256",key.as_slice(),iv.as_slice(),msg).unwrap();
        // println!("{}",res.clone().as_str());
        let res = aes_cbc_decode("256",key.as_slice(),iv.as_slice(),res.as_slice()).unwrap();
        assert_eq!(msg.to_vec(),res,"failed");
        println!("{}",res.as_str())
    }
    #[test]
    fn test_aes_ecb(){
        let key = rang_bytes(32);
        let msg = "hello world 我是好人".as_bytes();
        let en_msg = aes_ecb_encode("256",key.as_slice(),msg).unwrap();
        let de_msg = aes_ecb_decode("256",key.as_slice(),en_msg.as_slice()).unwrap();
        println!("{}",String::from_utf8_lossy(de_msg.as_slice()).to_string());
        // assert_eq!(msg.as_str(),de_msg.as_str())
    }
}